package kandl.automation.steprunner.selenium.commands;


import kandl.automation.steprunner.selenium.Command;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.springframework.stereotype.Component;

@Component
class LinkPresent implements Command {
    @Override
    public void runCommand(WebDriver driver, String... params) throws Exception {
        WebElement webElement = driver.findElement(By.linkText(params[0]));
        if (!webElement.isDisplayed()){
            throw new WebElementNotFoundException(params[0] + " is not found.");
        }
    }

    @Override
    public String getName() {
        return "link_present";
    }
}